<extend name="Public/base"/>

<block name="body">
	<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
	<div class="main-title">
		<h2>Banner编辑</h2>
	</div>
	<div class="tab-wrap">
		<div class="tab-content">
			<form action="__URL__/update" method="post" class="form-horizontal" enctype="multipart/form-data">
				<input type="hidden" name="id" value="{$vo.id}" />
				<!-- 基础 -->
				<div id="tab1" class="tab-pane in tab1">
					<div class="form-item">
						<!-- <label class="item-label">
							开始日期<span class="check-tips"></span>
						</label>
						<div class="controls">
							<input type="text" name="start_date" class="text date" value="{$vo.start_date}">
							<span class="check-tips"></span>
						</div>
						<label class="item-label">
							截止日期<span class="check-tips"></span>
						</label>
						<div class="controls">
							<input type="text" name="end_date" class="text date" value="{$vo.end_date}">
							<span class="check-tips"></span>
						</div> -->
						<label class="item-label">
							名称<span class="check-tips"></span>
						</label>
						<div class="controls">
							<input type="text" name="title" class="text input-large" value="{$vo.title}"><span class="check-tips"></span>
						</div>
						<label class="item-label">
							位置<span class="check-tips"></span>
						</label>
						<div class="controls">
							<select name="pos_id">
							<volist name="poslist" id="item">
							<option value="{$item.id}" <if condition="$item.id eq $vo['pos_id']">selected</if>>{$item.title}</option>
							</volist>
							</select>
							<span class="check-tips"></span>
						</div>
						<label class="item-label">
							图片<span class="check-tips">（建议尺寸：700*400）</span>
						</label>
						<div class="controls">
						<div class="controls">
							<input type="file" id="z_image">
							<input type="hidden" name="image" id="image_id" value=""/>
							<div class="upload-img-box">
								<div class="upload-pre-item"><img src="{$vo.image}"/></div>
							</div>
						</div>
						<script type="text/javascript">
							//上传图片
						    /* 初始化上传插件 */
							$("#z_image").uploadify({
						        "height"          : 30,
						        "swf"             : "/Public/static/uploadify/uploadify.swf",
						        "fileObjName"     : "download",
						        "buttonText"      : "上传图片",
						        "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
						        "width"           : 120,
						        'removeTimeout'	  : 1,
						        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
						        "onUploadSuccess" : z_image_id,
						        'onFallback' : function() {
						            alert('未检测到兼容版本的Flash.');
						        }
						    });
							function z_image_id(file, data){
						    	var data = $.parseJSON(data);
						    	var src = '';
						        if(data.status){
						        	$("#image_id").val(data.path);
						        	src = data.url || '' + data.path
						        	$("#image_id").parent().find('.upload-img-box').html(
						        		'<div class="upload-pre-item"><img src="' + src + '"/></div>'
						        	);
						        } else {
						        	updateAlert(data.info);
						        	setTimeout(function(){
						                $('#top-alert').find('button').click();
						                $(that).removeClass('disabled').prop('disabled',false);
						            },1500);
						        }
						    }
						</script>
						</div>
							
						<!-- <label class="item-label">
							链接地址<span class="check-tips"></span>
						</label>
						<div class="controls">
							<input type="text" name="link_url" class="text input-large" value="{$vo.link_url}"><span class="check-tips"></span>
						</div> -->
						
						<label class="item-label">链接类型</label>
						<div class="controls">
							<select name="link_type">
								<option value="0">请选择链接类型</option>
								<volist name="typearr" id="v">
								<option value="{$key}">{$v}</option>
								</volist>
							</select>
						</div>
						
						<label class="item-label">链接参数值</label>
						<div class="controls">
							<select name="link_value">
								<option value="0">请选择</option>
								
							</select>
						</div>
						<label class="item-label">
							排列序号<span class="check-tips"></span>
						</label>
						<div class="controls">
							<input type="text" name="order_num" class="text input-large" value="{$vo.order_num}"><span class="check-tips"></span>
						</div>
					</div>
				</div>

				<div class="form-item">
					<input type="hidden" name="__forward__" class="text input-large" value="{$__forward__}">
					<input type="hidden" name="position_id" class="text input-large" value="{$vo['position_id']}"><span class="check-tips"></span>
					<button type="submit" id="submit" class="btn submit-btn ajax-post" target-form="form-horizontal">确 定</button>
					<button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
				</div>
			</form>
		</div>
	</div>
</block>
<block name="script">
<script type="text/javascript">
//导航高亮
highlight_subnav('{:U('Focus/index')}');
$(function(){
	$("select[name='link_type']").change(function(){
		$("select[name='link_value']").html('');
		var str = '';
		var type = $("select[name='link_type']").val();
		
		$.ajax({
		 	type: 'GET',
		 	url: "{:U('getList')}",
		 	dataType: 'json',
		 	data:{type:type},
		 	success: function(data){
		 		str +='<option value="0">请选择</option>';
		 		if(data.length>0){
					for(var i=0;i<data.length;i++){
						str += '<option value="'+data[i].id+'">'+data[i].title+'</option>';
					}
				}
				$("select[name='link_value']").append(str);
		 	}
		});
		
		
	});
});
</script>
</block>
